from peewee import BigAutoField, CharField, IntegerField, BigIntegerField

from common.model.abstrct import AbstractModel


class TotalAttributeKey(AbstractModel):

    class Meta:
        table_name = "tb_attribute_key"
        auto_increment_base = 100_000
        indexes = (
            (("attribute_key_code", ), True),
        )

    attribute_id = BigAutoField(primary_key=True, help_text="属性id")
    attribute_key_code = CharField(max_length=32, help_text="便于比较属性名是否存在 md5计算")
    attribute_name = CharField(max_length=32, help_text="属性名")


class TotalAttributeValue(AbstractModel):

    class Meta:
        table_name = "tb_attribute_value"
        auto_increment_base = 100_000
        indexes = (
            (("attribute_key_id", "attribute_value_code"), True),  # 同一个属性名下面不能存在重复的属性值
        )

    attribute_value_id = BigAutoField(primary_key=True)
    attribute_key_id = BigIntegerField(help_text="属性key id")
    attribute_value_code = CharField(max_length=32, help_text="便于比较属性值是否存在, md5计算")
    attribute_value = CharField(max_length=32, help_text="属性值")


